
package com.tool.btn;

import com.tool.image.ImageMixDeal;
import com.tool.imagemonitor.PlayerMonitor;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import come.tool.Fighting.FightingMixDeal;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.MouseEvent;
import org.come.Frame.TeamJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.*;
import org.come.bean.RoleShow;
import org.come.bean.TeamBean;
import org.come.control.JirenjiaobenchuliControl;
import org.come.entity.TeamRole;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.*;

public class TeamPanelBtn extends MoBanBtn {
    private TeamApplyJpanel teamApplyJpanel;
    private TeamJpanel teamJpanel;
    private ZhuJpanel zhuJpanel;
    private TestpackJapnel testpackJapnel;
    private TeamPostMessageJpanel messageJpanel;
    private int index;

    public TeamPanelBtn(String iconpath, int type, String text, TeamJpanel teamJpanel, TeamApplyJpanel teamApplyJpanel) {
        super(iconpath, type);
        this.setText(text);
        this.setFont(UIUtils.TEXT_FONT1);
        this.setForeground(Color.orange);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.teamJpanel = teamJpanel;
        this.teamApplyJpanel = teamApplyJpanel;
    }

    public TeamPanelBtn(String iconpath, int type, String text, Color[] colors, Font font, TeamJpanel teamJpanel, TeamApplyJpanel teamApplyJpanel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.teamJpanel = teamJpanel;
        this.teamApplyJpanel = teamApplyJpanel;
    }

    public TeamPanelBtn(String iconpath, int type, String text, Color[] colors, Font font, ZhuJpanel zhuJpanel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.zhuJpanel = zhuJpanel;
    }

    public TeamPanelBtn(String iconpath, int type, String text, Color[] colors, Font font, TestpackJapnel testpackJapnel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.testpackJapnel = testpackJapnel;
    }

    public TeamPanelBtn(String iconpath, int type, String text, Color[] colors, Font font) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
    }

    public TeamPanelBtn(String iconpath, int type, String text, Color[] colors, Font font, TeamPostMessageJpanel messageJpanel) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.messageJpanel = messageJpanel;
    }

    public TeamPanelBtn(String iconpath, int type, int index, Color[] colors, Font font) {
        super(iconpath, type, colors);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.index = index;
    }





    @Override
    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(MouseEvent e) {
        if (FightingMixDeal.State == 0) {
            RoleShow roleShow = ImageMixDeal.userimg.getRoleShow();
            if (!"解散队伍".equals(this.getText()) && !"离开队伍".equals(this.getText())) {

                String sendmes;
                TeamRole teamRole;

                if ("移交队长".equals(this.getText()) && roleShow.getCaptian() == 1) {
                    teamRole = this.teamJpanel.getXZ();
                    this.teamJpanel.upXz(-1);
                    if (teamRole == null) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你没有选中的玩家");
                        return;
                    }

                    if (teamRole.getRoleId().compareTo(roleShow.getRole_id()) == 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("不能选中你自己");
                        return;
                    }

                    sendmes = Agreement.getAgreement().team5Agreement("S" + teamRole.getRoleId());
                    SendMessageUntil.toServer(sendmes);
                } else if ("请离队伍".equals(this.getText()) && roleShow.getCaptian() == 1) {
                    teamRole = this.teamJpanel.getXZ();
                    this.teamJpanel.upXz(-1);
                    if (teamRole == null) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你没有选中的玩家");
                        return;
                    }

                    if (teamRole.getRoleId().compareTo(roleShow.getRole_id()) == 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("不能选中你自己");
                        return;
                    }

                    sendmes = Agreement.getAgreement().team5Agreement("K" + teamRole.getRoleId());
                    SendMessageUntil.toServer(sendmes);
                } else if ("申请列表".equals(this.getText()) && roleShow.getCaptian() == 1) {
                    sendmes = Agreement.getAgreement().team6Agreement("");
                    SendMessageUntil.toServer(sendmes);
                } else if ("加为好友".equals(this.getText())) {
                    teamRole = this.teamJpanel.getXZ();
                    if (teamRole == null) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你没有选中的玩家");
                        return;
                    }

                    if (teamRole.getRoleId().compareTo(roleShow.getRole_id()) == 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("不能选中你自己");
                        return;
                    }

                    PlayerMonitor.addFriend(teamRole.getRoleId(), teamRole.getName());
                } else if ("允许".equals(this.getText())) {
                    this.teamApplyJpanel.teamAgree();
                } else if ("拒绝".equals(this.getText())) {
                    this.teamApplyJpanel.teamRefruse();
                } else if ("清空".equals(this.getText())) {
                    this.teamApplyJpanel.teamClear();
                } else if ("组队操作".equals(this.getText())) {
                    this.zhuJpanel.showIsTeamBtn(false, 0);
                    if (ImageMixDeal.userimg.getRoleShow().getTroop_id() != null) {
                        TeamJframe.getTeamJframe().getTeamjpanel().show(ImageMixDeal.userimg.getRoleShow(), RoleData.getRoleData().getTeamBean());
                        Music.addyinxiao("开关窗口.mp3");
                    } else {
                        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE2);
                        Music.addyinxiao("开关窗口.mp3");
                    }
                } else if ("坐骑".equals(this.getText())){
                    sendmes = Agreement.getAgreement().MountAgreement();
                    SendMessageUntil.toServer(sendmes);
                    ZhuFrame.getZhuJpanel().showflybtn(true,1);
               }else if ("飞行".equals(this.getText())){
                    sendmes = Agreement.getAgreement().FlyAgreement();
                    SendMessageUntil.toServer(sendmes);
                    ZhuFrame.getZhuJpanel().showflybtn(true,1);
               }
//                else if ("设置".equals(this.getText())){
//                    sendmes = Agreement.getAgreement().MountAgreement();
//                    SendMessageUntil.toServer(sendmes);
//                    ZhuFrame.getZhuJpanel().showflybtn1(true,1);
//                }else if ("退出游戏".equals(this.getText())){
//                    sendmes = Agreement.getAgreement().FlyAgreement();
//                    SendMessageUntil.toServer(sendmes);
//                    ZhuFrame.getZhuJpanel().showflybtn1(true,1);
//                }
                else if ("组队平台".equals(this.getText())) {
                    this.zhuJpanel.showIsTeamBtn(false, 0);
                    sendmes = Agreement.getAgreement().enlistAgreement("");
                    SendMessageUntil.toServer(sendmes);
                    Music.addyinxiao("开关窗口.mp3");
               } else if ("立即发布".equals(this.getText())) {
                    TeamBean teamBean = new TeamBean();
                    teamBean.seteTask(this.messageJpanel.getChooseRestrainStr(1));
                    teamBean.seteTeam(this.messageJpanel.getChooseRestrainStr(2));
                    teamBean.seteMsg(this.messageJpanel.getSendBelTextArea().getText());
                    sendmes = Agreement.getAgreement().enlistAgreement(GsonUtil.getGsonUtil().getgson().toJson(teamBean));
                    SendMessageUntil.toServer(sendmes);
                    FormsManagement.HideForm(19);
                } else if (!"暂离队伍".equals(this.getText()) && !"离".equals(this.getText())) {
                    if (!"回归队伍".equals(this.getText()) && !"归".equals(this.getText())) {
                        if ("召回".equals(this.getText()) || "召".equals(this.getText())) {
                            sendmes = Agreement.getAgreement().team4Agreement("C" + ((TeamRole)RoleData.getRoleData().getTeamBean().getTeams().get(this.index)).getRoleId());
                            SendMessageUntil.toServer(sendmes);
                        }
                    } else {
                        sendmes = Agreement.getAgreement().team4Agreement("R");
                        SendMessageUntil.toServer(sendmes);
                    }
                } else {
                    sendmes = Agreement.getAgreement().team4Agreement("L");
                    SendMessageUntil.toServer(sendmes);
                }
            } else {
            	String sendmes = Agreement.getAgreement().team5Agreement("D");
                SendMessageUntil.toServer(sendmes);
                FormsManagement.HideForm(13);
                JirenjiaobenchuliControl.name=null;
                JirenjiaobenchuliControl.duizhang=null;
            }

        }
    }
}
